﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IteratorsCompsing
{
    class Program
    {
        //static void Main()
        //{
        //    foreach (int fib in Fibs(6))
        //        Console.WriteLine(fib);
        //}
        //static IEnumerable<int> Fibs(int fibCount)
        //{
        //    for (int i = 0, prevFib = 1, curFib = 1; i < fibCount; i++)
        //    {
        //        yield return prevFib;
        //        int newFib = prevFib + curFib;
        //        prevFib = curFib;
        //        curFib = newFib;
        //    }
        //}
        //static IEnumerable<int> EvenNumbersOnly(IEnumerable<int> sequence)
        //{
        //    foreach (int x in sequence)
        //        if ((x % 2) == 0)
        //            yield return x;
        //}

        static void Main()
        {
            foreach (string s in Foo())
                Console.WriteLine(s); // Prints "One","Two","Three"
        }
        static IEnumerable<string> Foo()
        {
            yield return "One";
            yield return "Two";
            yield return "Three";
        }

    }
}
